package net.comm.group.db;


import java.sql.ResultSet;
import java.sql.SQLException;

import net.comm.group.bean.BaseGparty;
import net.comm.user.bean.BaseUsers;
import net.comm.user.service.impl.UsersServiceImpl;
import net.comm.util.StringUtil;

import org.apache.log4j.Logger;
import org.sakaiproject.db.api.SqlReader;

public class DbGpartyService implements SqlReader
{
	static Logger logger = Logger.getLogger(DbGpartyService.class.getName());
	/**
	 * Read from the result one set of fields to create a Resource.
	 * 
	 * @param result
	 *        The Sql query result.
	 * @return The Resource object.
	 */
	public Object readSqlResultRecord(ResultSet result)
	{
		try
		{
			int  	partyID = result.getInt(1);			//	活动序号
			int  	groupID = result.getInt(2);			//	群组ID
			String  title = StringUtil.getValue(result.getString(3));				//	活动主题
			String  info = StringUtil.getValue(result.getString(4));			//	介绍
			int  	smallPic = result.getInt(5);			//	活动首页小海报ID
			String  bgtime = StringUtil.getValue(result.getString(6));			//	活动起始日期时间
			String  endtime = StringUtil.getValue(result.getString(7));		//	活动结束日期时间
			int  	work_location = result.getInt(8);		//	活动省份
			int  	work_sublocation = result.getInt(9);	//	活动城市
			int  	firsort = result.getInt(10);			//	分类一
			int  	secsort = result.getInt(11);			//	分类二
			int  	thisort = result.getInt(12);			//	分类三			
			String  place = StringUtil.getValue(result.getString(13));			//	地点
			String  tel = StringUtil.getValue(result.getString(14));			//	联系方式
			String  signEtime = StringUtil.getValue(result.getString(15));		//	报名截止时间
			String  charge = StringUtil.getValue(result.getString(16));			//	活动费用
			int  	planNum = result.getInt(17);								//	计划活动人数
			int  	signNum = result.getInt(18);								//	目前报名人数
			String  organType = StringUtil.getValue(result.getString(19));		//	组织人类型
			int  	userID = result.getInt(20);									//	组织人ID
			String  ctime = StringUtil.getValue(result.getString(21));			//	发起日期
			int  	attach = result.getInt(22);									//	点击数
			int  	upCnt = result.getInt(23);									//	点击数
			int  	downCnt = result.getInt(24);									//	点击数
			String  status = StringUtil.getValue(result.getString(25));			//	状态
			String  mtime = StringUtil.getValue(result.getString(26));			//	最后修改日期时间

			// create the Resource from these fields
			return new BaseGparty( partyID,  groupID,  title,  info, smallPic,  bgtime,  endtime,  work_location,
					 work_sublocation,  firsort,  secsort,  thisort,place,  tel,  signEtime,  charge,
					 planNum,  signNum,  organType,  userID, ctime,  attach, upCnt, downCnt, status,  mtime );
		}
		catch (SQLException e)
		{
			logger.error(e.getMessage());
			return null;
		}
		
	}
}
